//
//  imagePicker.m
//  EFExtend
//
//  Created by mac on 15/7/6.
//  Copyright (c) 2015年 Eric. All rights reserved.
//

#import "imagePicker.h"


@interface imagePicker ()

@end

@implementation imagePicker

- (void)dealloc
{
   
    HM_SUPER_DEALLOC();
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    
    [self.customNavLeftBtn setImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal];
    [self.customNavLeftBtn setFrame:CGRectMakeBound(32, 32)];
    
    
    [[[[[[[[[UIView viewAsButten]
     EFTagString:@"photo"]
         EFOwner:self.view]
        EFText:@"photo"]
       EFTextColor:[UIColor blueColor]]
        addViewStyle:[HMUISolidFillStyle styleWithColor:[UIColor md_amber_400] next:nil]]
       EFEdgeInsets:UIEdgeInsetsAll(5)]
      addViewStyle:[HMUISolidBorderStyle styleWithColor:[UIColor redColor] width:1 next:nil]]
      
     mas_makeConstraints:^(MASConstraintMaker *make) {
         make.top.mas_equalTo(self.view.mas_top).offset(10);
         make.left.mas_equalTo(self.view.mas_left).offset(10);
         make.height.mas_equalTo(40);
         make.right.mas_equalTo(self.view.mas_right).offset(-10);
     }];
    
    
    ShapePathAction action = ^(CGContextRef context, CGRect rect){
        CGMutablePathRef ref = CGPathCreateMutable();
        CGPathAddArc(ref, NULL, 10, 10, 10, 0, 270, NO);
        CGPathMoveToPoint(ref, NULL, 50, 10);
        CGPathAddArc(ref, NULL, 40, 10, 10, 0, 270, NO);
        CGPathMoveToPoint(ref, NULL, 80, 10);
        CGPathAddArc(ref, NULL, 70, 10, 10, 0, 270, NO);
        CGPathMoveToPoint(ref, NULL, 110, 10);
        CGPathAddArc(ref, NULL, 100, 10, 10, 0, 270, NO);
        CGContextAddPath(context, ref);
        CGPathRelease(ref);
    };

    [[[[[[[[HMUIView spawn] EFOwner:self.view]
     EFFrame:CGRectMake(10, 60, 300, 40)]
       addViewStyle:[HMUISolidFillStyle styleWithColor:[UIColor md_amber_400] next:nil]]
       addViewStyle:[HMUIInsetStyle styleWithInset:UIEdgeInsetsAll(5) next:nil]]
       addViewStyle:[HMUIShapeStyle styleWithShape:[HMUIPathShape shapeWithPath:action] next:nil]]
      addViewStyle:[HMUISolidFillStyle styleWithColor:[UIColor md_amber_200] next:nil]]
      addViewStyle:[HMUISolidBorderStyle styleWithColor:[UIColor redColor] width:1 next:nil]];
    
    self.camera = [[HMUICamera alloc]init];
    self.camera.viewControllerForPresentingImagePickerController = self;
    self.camera.delegate = self;
    self.camera.allowsEditingPhoto = YES;
    self.camera.cancelText = @"取消";
    self.camera.takePhotoText = @"拍照";
    self.camera.chooseFromLibraryText = @"相册";
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

ON_Button(signal){
    UIButten *btn = signal.source;
    if ([signal is:[UIButten TOUCH_UP_INSIDE]]) {
        if ([btn is:@"leftBtn"]) {//customNavLeftBtn
            [self backAndRemoveWithAnimate:YES];
        }else if ([btn is:@"rightBtn"]){//customNavRightBtn
            
        }else if ([btn is:@"photo"]){
            [self.camera takePhotoOrChooseFromLibrary];
        }
    }
}

@end
